package com.example.auth.service.impl;

import com.example.auth.service.SendCodeService;
import org.example.utils.JedisUtil;
import org.example.utils.SendMsgCode;
import org.springframework.stereotype.Service;

@Service
public class SendCodeServiceImpl implements SendCodeService {
    @Override
    public boolean getPhoneCode(String key,String phone) { return SendMsgCode.code(phone,key); }
    @Override
    public boolean existsCode(String key,String code) {
        System.out.println(JedisUtil.get(key)+" "+code);
        try {
            if (JedisUtil.get(key).equals(code)){
                JedisUtil.delete(key);//删除还存在redis的验证码
                return true;
            }else{
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}
